<?php
include "../include/global.php";
include "../include/admin_check.php";
include "setting.php";

$ID=intval($_GET['ID']);
$page=intval($_GET['page']);
if($ID){
	$stsql = "SELECT news_image FROM ".pre_table."news WHERE news_id='$ID'";
	$rs_img = recordset($stsql);

	if($rs_img[news_image]){
		$Image_del = deletefile($path.$rs_img[news_image]);
	}

	
	$stsql = "DELETE FROM ".pre_table."news WHERE news_id='$ID'";
	$rs = execSQL($stsql);
	echo "<script language = 'javascript'>
			location.href = 'news.php?page=$page';
		</script>";
	exit(); 
}else{
	$stsql = "SELECT news_image FROM ".pre_table."news WHERE news_id='$img'";
	$rs_img = execSQL($stsql);
	while($row_img=mysql_fetch_array($rs_img)){
		for($j=0;$j<count($MAX_THUMB_WIDTH);$j++){
			deletefile($path."thumb_".$MAX_THUMB_WIDTH[$j]."_".$row_img[news_image]);
		}
		if($row_img[news_image]){
			$Image_del = deletefile($path.$row_img[news_image]);
		}
	}
	//
	$stsql = "UPDATE ".pre_table."news SET news_image='' WHERE news_id='$img'";
	$rs = execSQL($stsql);
	
	echo "<script language = 'javascript'>
			location.href = 'newsWrite.php?ID=$img&page=$page';
		</script>";
	exit(); 
}


?>

